#include "stdafx.h"
#include<cmath>
#include <cstdlib>
#include "random.h"

using namespace std;


int random::poisson(double mean)   
  {   
	   srand((unsigned)time(NULL));
       double product=(rand()+0.0)/RANDOM_MAX;   
       double limit=exp(-mean);     
       int    count=0;   
       while(product>limit)   
          {   
              count++;
		      product*=(rand()+0.0)/RANDOM_MAX;
	      }
	   return count;       
  } 